package com.itheima.config;


import com.itheima.common.utils.AliOssUtils;
import com.itheima.properties.AliOssProperties;
import com.itheima.properties.FreeMarkerProperties;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;

/**
 * 配置类，用于创建AliOssUtil对象
 */
@Configuration
public class FreeMarkerApplicationConfiguration {

    @Bean(name = "freeMarkerConfigurer")
    @ConditionalOnMissingBean
    public FreeMarkerConfigurer freeMarkerConfigurer(FreeMarkerProperties freeMarkerProperties){
        FreeMarkerConfigurer configurer = new FreeMarkerConfigurer();
        configurer.setDefaultEncoding("UTF-8");
        configurer.setTemplateLoaderPath(freeMarkerProperties.getTemplateLoaderPath());

        return configurer;
    }
}